const fs = require("fs");
const path = require("path");
const createRespHeader = (header) => {
    return Object.assign({
        "responseseq": "123",
        "rsptime": new Date(),
        "rspcode": "0000",
        "rspdesc": "竟然成功"
    }, header)
}
const createResp = (resp) => {
    let header = {};
    let response = {};
    if (resp.header && resp.response) {
        header = resp.header;
        response = resp.response;
    } else {
        response = resp
    }
    return {
        "header": createRespHeader(header),
        response
    }

}
const db = {};
fs.readdirSync(path.join(__dirname, "../data")).forEach(k => {
    let a = k.substr(0, k.length - 3);
    let b = a.split("-")[0] + "/" + a.split("-")[1];
    try {
        db[k.split(".")[0]] = createResp(require(`../data/${k}`))
        // db[b] = createResp(require(`../data/${a}`))
    } catch (err) {
    
    }
   

})


module.exports = () => db;
